package com.hrbxlh.virtualization.param;

import com.hrbxlh.virtualization.pojo.ImageAllocation;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author cheer
 */
public class ImageAllocationConfirmParam {

    /**
     * 课程Id
     */
    @NotNull(message = "课程Id不能为空")
    private Integer courseId;

    /**
     * 章节Id集合
     */
    @NotEmpty(message = "没有选择镜像")
    private List<Integer> chapterIds;

    /**
     * 是否为集群，true为集群，false为单节点
     */
    @NotNull(message = "镜像类型不能为空")
    private Boolean cluster;

    /**
     * 如果是单节点，镜像Id
     */
    private Long imageId;

    /**
     * 如果是集群，集群Id
     */
    private Long clusterId;

    /**
     * 配置
     */
    @NotBlank(message = "配置不能为空")
    private String flavor;

    public ImageAllocation convertToImageAllocation(Integer chapterId) {
        ImageAllocation imageAllocation = new ImageAllocation();
        BeanUtils.copyProperties(this, imageAllocation);
        imageAllocation.setChapterId(chapterId);
        return imageAllocation;
    }

    public Integer getCourseId() {
        return courseId;
    }

    public void setCourseId(Integer courseId) {
        this.courseId = courseId;
    }

    public List<Integer> getChapterIds() {
        return chapterIds;
    }

    public void setChapterIds(List<Integer> chapterIds) {
        this.chapterIds = chapterIds;
    }

    public Boolean getCluster() {
        return cluster;
    }

    public void setCluster(Boolean cluster) {
        this.cluster = cluster;
    }

    public Long getImageId() {
        return imageId;
    }

    public void setImageId(Long imageId) {
        this.imageId = imageId;
    }

    public Long getClusterId() {
        return clusterId;
    }

    public void setClusterId(Long clusterId) {
        this.clusterId = clusterId;
    }

    public String getFlavor() {
        return flavor;
    }

    public void setFlavor(String flavor) {
        this.flavor = flavor;
    }
}
